package com.gardenguell.salad.data.util;

import java.security.MessageDigest;

/**
 * Created by absurd on 16/3/2.
 */
public class EncryptUtil {


    public static String md5(String message) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            return hex(md.digest(message.getBytes("CP1252")));
        } catch (Exception ignored) {

        }
        return message;
    }


    private static String hex(byte[] array) {
        StringBuilder sb = new StringBuilder();
        for (byte anArray : array) {
            sb.append(Integer.toHexString((anArray & 0xFF) | 0x100).substring(
                    1, 3));
        }
        return sb.toString();
    }



}
